﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class TeacLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ibtnSubmit_Click(object sender, EventArgs e)
        {
            #region 假如浏览器禁用Cookies，则提示用户开启Cookies
            if (Request.Cookies["ValidateCode"] == null)
            {
                string strMessage = string.Format("alert('您的浏览器设置已禁用Cookies，您必须启用浏览器的Cookies选项后才能使用本系统!')");
                this.ClientScript.RegisterStartupScript(this.GetType(), "", strMessage, true);
                return;
            }
            #endregion

            if (string.Compare(Request.Cookies["ValidateCode"].Value, txtValidate.Text.Trim()) != 0)
            {
                lblError.InnerText = "验证码错误!";
                return;
            }
            Model.Teachers tea = new Model.Teachers() { teacherID = txtTeacherID.Text.Trim(), teacherPwd = txtTeacherPwd.Text };
            if (!BLL.LoginManager.TeacherLogin(tea))
            {
                lblError.InnerText = "用户名或密码错误!";
                return;
            }
            Session["teacherID"] = txtTeacherID.Text.Trim();
            Response.Redirect("./TeachOrder.aspx");

        }

    }
}